<template>
  <div>
      <p v-for="item of hots" :key="item">
          <button @click="changeCity(item)">{{item}} </button>
      </p>
      <p>{{ this.$store.state.num }}</p>
  </div>
</template>

<script>
export default {
    data() {
        return {
            hots:["武汉","上海","杭州"]
        }
    },
    methods: {
        changeCity(val){
            console.log(val);
            this.$store.dispatch("changeCity",val);
            this.$router.back()
        }
    },
}
</script>

<style>

</style>